<template>
  <ve-radar :data="chartData" :extend="extend" :settings="chartSettings"></ve-radar>
</template>

<script>
import {
  mapActions,
  mapGetters
} from 'vuex'
import {
  selectProresult
} from '@/network/home'
  export default {
    props: ["userId"],
    data() {
      this.extend = {
        //样式
        textStyle: {
          color: '#000'
        }
      }
      this.chartSettings = {
        // dimension: ["得分"],
        // metrics: ['创新能力','大局观','服务意识','沟通协调能力','工作方法','计划能力','积极进取','纪律性','抗压能力','领导能力','理解判断力','时间管理','团队意识','学习能力','责任感','执行能力','专业技能','组织能力'],
        // metrics: ['cx','dj','fw','gt','gz','jh','jj','jl','ky','ld','lj','sj','td','xx','zr','zx','zy','zz'],
        labelMap: {
          cx: '创新能力',
          dj: '大局观',
          fw: '服务意识',
          gt: '沟通协调能力',
          gz: '工作方法',
          jh: '计划能力',
          jj: '积极进取',
          jl: '纪律性',
          ky: '抗压能力',
          ld: '领导能力',
          lj: '理解判断力',
          sj: '时间管理',
          td: '团队意识',
          xx: '学习能力',
          zr: '责任感',
          zx: '执行能力',
          zy: '专业技能',
          zz: '组织能力'
        }
      }
      return {
        chartData: {
          columns: [
            "得分","cx","dj","fw","gt","gz","jh","jj","jl","ky","ld","lj","sj","td","xx","zr","zx","zy","zz"
          ],
          rows: [
            {"得分":"最低:0","cx":0,"dj":0,"fw":0,"gt":0,"gz":0,"jh":0,"jj":0,"jl":0,"ky":0,"ld":0,"lj":0,"sj":0,"td":0,"xx":0,"zr":0,"zx":0,"zy":0,"zz":0},
            {"得分":"最高:5","cx":5,"dj":5,"fw":5,"gt":5,"gz":5,"jh":5,"jj":5,"jl":5,"ky":5,"ld":5,"lj":5,"sj":5,"td":5,"xx":5,"zr":5,"zx":5,"zy":5,"zz":5},
            // {"得分":"你的得分","cx":1,"dj":3,"fw":3,"gt":4,"gz":3,"jh":2,"jj":3,"jl":3,"ky":4,"ld":2,"lj":4,"sj":4,"td":4,"xx":3,"zr":3,"zx":2,"zy":3,"zz":4},
            {"得分":"你的得分","cx":0,"dj":0,"fw":0,"gt":0,"gz":0,"jh":0,"jj":0,"jl":0,"ky":0,"ld":0,"lj":0,"sj":0,"td":0,"xx":0,"zr":0,"zx":0,"zy":0,"zz":0},
            // {'能力': '最低:0',
            // '创新能力': 0,
            // '大局观': 0,
            // '服务意识': 0,
            // '沟通协调能力': 0,
            // '工作方法': 0,
            // '计划能力': 0,
            // '积极进取': 0,
            // '纪律性': 0,
            // '抗压能力': 0,
            // '领导能力': 0,
            // '理解判断力': 0,
            // '时间管理': 0,
            // '团队意识': 0,
            // '学习能力': 0,
            // '责任感': 0,
            // '执行能力': 0,
            // '专业技能': 0,
            // '组织能力': 0,
            // '钻研能力': 0,
            // '专业知识': 0},
            // {'能力': '最高:5',
            // '创新能力': 5,
            // '大局观': 5,
            // '服务意识': 5,
            // '沟通协调能力': 5,
            // '工作方法': 5,
            // '计划能力': 5,
            // '积极进取': 5,
            // '纪律性': 5,
            // '抗压能力': 5,
            // '领导能力': 5,
            // '理解判断力': 5,
            // '时间管理': 5,
            // '团队意识': 5,
            // '学习能力': 5,
            // '责任感': 5,
            // '执行能力': 5,
            // '专业技能': 5,
            // '组织能力': 5,
            // '钻研能力': 5,
            // '专业知识': 5},
            // {"能力":"得分","创新能力":5,"大局观":3,"服务意识":3,"沟通协调能力":4,"工作方法":3,"计划能力":2,"积极进取":3,"纪律性":3,"抗压能力":4,"领导能力":2,"理解判断力":4,"时间管理":4,"团队意识":4,"学习能力":3,"责任感":3,"执行能力":2,"专业技能":3,"组织能力":4,"钻研能力":3,"专业知识":4}
            // {}
          ]
        }
      }
    },
    computed: {
      ...mapGetters([
        'userinfo'
      ]),
    },
    created() {
      this.selectproresult()
    },
    methods: {
      ...mapActions([
        'selectProresult'
      ]),
      selectproresult() {
        let params = {
          user_Id: this.userId,
          questionType_Id: 10
        }
        selectProresult(params)
          .then((data) => {
            // this.chartData.columns = data.data.resultWeakness
            // console.log(data.data[0])
            // const obj = data.data[0].countScore
            // this.obj = JSON.parse(data.data[0].countScore)
            // console.log(this.obj)
            // this.chartData.rows[2] = this.$set(this.obj,"得分","你的得分")
            this.chartData.rows[2].cx = JSON.parse(data.data[0].countScore).cx
            this.chartData.rows[2].dj = JSON.parse(data.data[0].countScore).dj
            this.chartData.rows[2].fw = JSON.parse(data.data[0].countScore).fw
            this.chartData.rows[2].gt = JSON.parse(data.data[0].countScore).gt
            this.chartData.rows[2].gz = JSON.parse(data.data[0].countScore).gz
            this.chartData.rows[2].jh = JSON.parse(data.data[0].countScore).jh
            this.chartData.rows[2].jj = JSON.parse(data.data[0].countScore).jj
            this.chartData.rows[2].jl = JSON.parse(data.data[0].countScore).jl
            this.chartData.rows[2].ky = JSON.parse(data.data[0].countScore).ky
            this.chartData.rows[2].ld = JSON.parse(data.data[0].countScore).ld
            this.chartData.rows[2].lj = JSON.parse(data.data[0].countScore).lj
            this.chartData.rows[2].sj = JSON.parse(data.data[0].countScore).sj
            this.chartData.rows[2].td = JSON.parse(data.data[0].countScore).td
            this.chartData.rows[2].xx = JSON.parse(data.data[0].countScore).xx
            this.chartData.rows[2].zr = JSON.parse(data.data[0].countScore).zr
            this.chartData.rows[2].zx = JSON.parse(data.data[0].countScore).zx
            this.chartData.rows[2].zy = JSON.parse(data.data[0].countScore).zy
            this.chartData.rows[2].zz = JSON.parse(data.data[0].countScore).zz
            // this.chartData.rows[2] = data.data[0].countScore
            // console.log(this.chartData.rows[2])
          })
          .catch((err) => {
            // this.$toast(err.msg, 'error')
          })
      },
    }
  }
</script>